home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / pvm34b3.zip / pvm34b3 / pvm3 / libfpvm / pvmfgetinfo.m4 < prev    next >
Text File  |  1997-07-22  |  2KB  |  84 lines

  1.  
  2. /* $Id: pvmfgetinfo.m4,v 1.4 1997/05/08 13:32:56 pvmsrc Exp $ */
  3.  
  4. #include "pvm3.h"
  5. #include "pvm_consts.h"
  6.  
  7. void
  8. FUNCTION(pvmfgetmboxinfo)
  9.     ARGS(`STRING_ARG(pattern),
  10.         STRING_ARG(name),
  11.         nclassesp,
  12.         nentriesp,
  13.         indexp,
  14.         ownerp,
  15.         flagp,
  16.         infop')
  17.  
  18.     STRING_ARG_DECL(pattern);
  19.     STRING_ARG_DECL(name);
  20.     int *nclassesp, *nentriesp, *indexp, *ownerp, *flagp, *infop;
  21. {
  22.     static struct pvmmboxinfo *classes = (struct pvmmboxinfo *) 0;
  23.     static int nclasses = 0;
  24.     static int next = 0;
  25.  
  26.     char tpattern[MAX_MBOX_NAME + 1];
  27.     int nc;
  28.     int cc;
  29.     int i;
  30.  
  31. /* if user sets nclassesp to -1 then pvmfgetmboxinfo() will be reset */
  32.  
  33.     if ( nclasses && nclassesp && (*nclassesp == -1) )
  34.         nclasses = 0;
  35.  
  36.     if ( !nclasses )
  37.     {
  38.         /*
  39.          *  Copy the pattern to make sure there is
  40.          *  a NUL at the end.
  41.          */
  42.         if ( ftocstr( tpattern, sizeof(tpattern), STRING_PTR(pattern),
  43.                 STRING_LEN(pattern) ) ) {
  44.             *infop = PvmBadParam;
  45.             return;
  46.         }
  47.  
  48.         if ( (cc = pvm_getmboxinfo( tpattern, &nc, &classes )) < 0 ) {
  49.             *infop = cc;
  50.             return;
  51.         }
  52.  
  53.         nclasses = nc;
  54.         next = 0;
  55.  
  56.         if ( !nclasses )
  57.             *infop = PvmNotFound;
  58.     }
  59.  
  60.     if ( next < nclasses )
  61.     {
  62.         if ( STRING_PTR(name) )
  63.             ctofstr( STRING_PTR(name), STRING_LEN(name),
  64.                     classes[ next ].mi_name );
  65.         if ( nentriesp ) *nentriesp = classes[ next ].mi_nentries;
  66.         if ( indexp ) {
  67.             for ( i=0 ; i < classes[ next ].mi_nentries ; i++ )
  68.                 indexp[i] = classes[ next ].mi_indices[i];
  69.         }
  70.         if ( ownerp ) {
  71.             for ( i=0 ; i < classes[ next ].mi_nentries ; i++ )
  72.                 ownerp[i] = classes[ next ].mi_owners[i];
  73.         }
  74.         if ( flagp ) {
  75.             for ( i=0 ; i < classes[ next ].mi_nentries ; i++ )
  76.                 flagp[i] = classes[ next ].mi_flags[i];
  77.         }
  78.     }
  79.  
  80.     if ( next == nclasses )
  81.         nclasses = 0;
  82. }
  83.  
  84.